from functools import reduce

#reduce()连续计算，连续调用lambda
list_x = [1,2,3,4,5,6,7,8]
#第三个参数作为初始值
print(reduce(lambda x,y:x+y,list_x))
print(reduce(lambda x,y:x*y,list_x))
print(reduce(lambda x,y:x+y,list_x,10))
print(reduce(lambda x,y:x*y,list_x,10))
#计算过程
#step1:1+2=3
#step2:3+3=6
#....
